<template>
  <div class="photoinfo">
    <h3>{{photoinfo.title}}</h3>
    <p class="subtitle">
      <span>发表时间：{{photoinfo.add_time|dataFormat}}</span>
      <span>点击:{{photoinfo.click}}次数</span>
    </p>

    <hr />

    <!-- 缩略图区域 -->
    <div class="image">
     <vue-preview :slides="list"></vue-preview>
    </div>

    <!-- 图片内容 -->
    <div class="content" v-html="photoinfo.content"></div>

    <!-- 评论组件 -->
    <pho-comment :id="id"></pho-comment>
  </div>
</template>

<script>
import { Toast } from "mint-ui";
import comment from "../soncomponent/comment.vue";
export default {

    
 
  data() {
    return {
      id: this.$route.params.id,
      photoinfo: {},
      list: [] //缩略图数组
    };
  },
  methods: {
    getPhoto() {
      this.$http.get("api/getimageinfo/" + this.id).then(result => {
        if (result.body.status === 0) {
          this.photoinfo = result.body.message[0];
        } else {
          Toast("获取失败");
        }
      });
    },
    getsmallphoto() {
      this.$http.get("api/getthumimages/" + this.id).then(result => {
        if (result.body.status === 0) {
          result.body.message.forEach(item => {
            item.w = 600;
            item.h = 400;
            item.msrc=item.src;
          });
          this.list = result.body.message;
        } else {
          Toast("获取失败");
        }
      });
    }
  },
  created() {
    this.getPhoto();
  },
  mounted() {
    this.getsmallphoto();
  },
  components: {
    "pho-comment": comment
  }
};
</script>
<style lang="scss">
.photoinfo {
  padding: 5px;
  h3 {
    color: lightskyblue;
    font-size: 15px;
    text-align: center;
    margin: 15px 0;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
  }
  .content {
    font-size: 12px;
    line-height: 30px;
  }
}

.image {
 height: auto;
 width: 100%;
 position: relative;
}
</style>